//
//  TrainingDetailViewController.m
//  jinneng
//
//  Created by mac on 2020/8/5.
//  Copyright © 2020 jznrj. All rights reserved.
//

#import "TrainingProcessionDetailViewController.h"
#import "FileListViewController.h"
@interface TrainingProcessionDetailViewController ()
@property(nonatomic,strong) JznWebView *jznWebView;
@property(nonatomic) int page;
@end


@implementation TrainingProcessionDetailViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    self.title = @"培训详情";
    // Do any additional setup after loading the view.
    [self initView];
}

-(void) initView{
   [self.view addSubview:self.jznWebView];
   [self.jznWebView mas_makeConstraints:^(MASConstraintMaker *make) {
        make.left.right.equalTo(self.view);
        if (@available(iOS 11.0, *)) {
            make.top.equalTo(self.view.mas_safeAreaLayoutGuideTop);
            make.bottom.equalTo(self.view.mas_safeAreaLayoutGuideBottom);
        } else {
            make.top.bottom.equalTo(self.view);
        }
    }];
    self.view.backgroundColor = [UIColor whiteColor];
    [self.jznWebView loadLocalFile:@"/ios_jinneng/training_procession_detail" type:@"html"];
    
    [self registJSFunction];
}

-(void) registJSFunction{
    [self.webViewBridge registerHandler:@"toFileList" handler:^(id data, WVJBResponseCallback responseCallback) {
        NSString *fileList = data[@"fileList"];
        
        dispatch_async(dispatch_get_main_queue(), ^(){
            FileListViewController *vc = [[FileListViewController alloc]init];
            vc.fileListString = fileList;
            [self.navigationController pushViewController:vc animated:YES];
        });
        
    }];
}

- (void)webView:(WKWebView *)webView didFinishNavigation:(null_unspecified WKNavigation *)navigation{
        NSString *clear = [NSString stringWithFormat:@"getTrainingClass(%@)",self.trainingInfo];
        //s[self.jznWebView stringByEvaluatingJavaScriptFromString: clear];
    [self.jznWebView evaluateJavaScript:clear completionHandler:^(id _Nullable data, NSError * _Nullable error) {
        
    }];
}

/*
#pragma mark - Navigation

// In a storyboard-based application, you will often want to do a little preparation before navigation
- (void)prepareForSegue:(UIStoryboardSegue *)segue sender:(id)sender {
    // Get the new view controller using [segue destinationViewController].
    // Pass the selected object to the new view controller.
}
*/

@end

